package com.sisyphus.spinach.helper.validation;

import android.text.TextUtils;
import android.widget.TextView;

/**
 * 不能为空
 */
public class FormNotEmpty implements IFormRule {

    private final CharSequence param;
    private       String       errorMessage;

    public FormNotEmpty(TextView param, String errorMessage) {
        this(param.getText(), errorMessage);
    }

    public FormNotEmpty(CharSequence param, String errorMessage) {
        this.param = param;
        this.errorMessage = errorMessage;
    }

    @Override
    public boolean validation() {
        return !TextUtils.isEmpty(param) && !TextUtils.isEmpty(param.toString().trim());
    }

    @Override
    public CharSequence getErrorMessage() {
        return errorMessage;
    }
}
